package com.zjy.pgcms.common.vo;

import com.zjy.pgcms.entity.User;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

@Data
public class UserInfoVO {
    private Long id;
    private String username;
    private String name;
    private String gender;
    private String phone;
    private String email;
    private String createTime;
    private String avatarUrl;

    public UserInfoVO(User user){
        this.id = user.getId();
        this.username = user.getUsername();
        String form = String.format("%tF", user.getCreateTime());
        this.createTime = form;
        this.avatarUrl = user.getAvatarUrl();
        if (StringUtils.isNotBlank(user.getName())){
            this.name = user.getName();
        }else {
            this.name = "未设置";
        }

        if (StringUtils.isNotBlank(user.getName())){
            this.name = user.getName();
        }else {
            this.name = "未设置";
        }

        if (user.getGender() == 0){
            this.gender = "女";
        }else {
            this.gender = "男";
        }

        if (StringUtils.isNotBlank(user.getPhone())){
            this.phone = user.getPhone();
        }else {
            this.phone = "未设置";
        }

        if (StringUtils.isNotBlank(user.getName())){
            this.email = user.getEmail();
        }else {
            this.email = "未设置";
        }



    }
}
